Skip to main content

SetTableLayout

Specifies the algorithm which will be used to lay out the contents of the current table within the document.

Syntax

expression.SetTableLayout(sType);

expression - A variable that represents a ApiTablePr class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTypeRequired"autofit""fixed"

Returns

This method doesn't return any data.

Example

This example specifies the algorithm which will be used to lay out the contents of the table within the document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("We set the table cells to preserve their size:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let tablePr = tableStyle.GetTablePr();
let table = Api.CreateTable(3, 3);
tablePr.SetTableLayout("fixed");
table.SetTableLook(true, true, true, true, false, false);
table.SetStyle(tableStyle);
let cell = table.GetRow(0).GetCell(0);
cell.GetContent().GetElement(0).AddText("Fixed layout");
doc.Push(table);